package gu.simplemq.redis;

import java.util.EnumMap;
import java.util.Properties;

import gu.simplemq.MQConstProvider;
import gu.simplemq.MQPropertiesHelper;
import gu.simplemq.redis.JedisPoolLazy.PropName;

public class PropertiesHelper extends MQPropertiesHelper {
	public static final PropertiesHelper RHELPER = new PropertiesHelper();

	PropertiesHelper() {
	}

	@Override
	public MQConstProvider getConstProvider() {
		return RedisConstProvider.RPROVIDER;
	}

	@Override
	public void checkConnect(Properties input, Integer timeoutMills)  {
		EnumMap<PropName, Object> props = initParameters(input).asEnumMap(PropName.class);
		if(timeoutMills != null && timeoutMills > 0){
			props.put(PropName.timeout, timeoutMills);
		}
		JedisUtils.checkConnect(props);
	}

	@Override
	public boolean testConnect(Properties input,Integer timeoutMills) {
		EnumMap<PropName, Object> props = initParameters(input).asEnumMap(PropName.class);
		if(timeoutMills != null && timeoutMills > 0){
			props.put(PropName.timeout, timeoutMills);
		}
		return JedisUtils.testConnect(props);
	}
}
